import Vue from 'vue'
import App from './App.vue'
import router from './router'
// 引入axios，并挂载至Vue原型上面
import axios from 'axios'
import VueAxios from 'vue-axios'
Vue.use(VueAxios, axios)
axios.defaults.baseURL = '/api';
axios.defaults.timeout = 1000;

// 使用axios拦截响应请求
axios.interceptors.response.use(function(response) {
    let res = response.data;
    if (res.status == 0) {
        return res.data
    } else if (res.status == 10) {
        window.location.href = '/#/login';
    } else {
        alert(res.msg);
    }
})

// 使用mockjs模拟数据
const mock = true;
if (mock) {
    require('./mock/api')
}

new Vue({
    router,
    render: h => h(App)
}).$mount('#app');